<?php
namespace app\admin\controller;

use think\facade\View;
use think\facade\Filesystem;
use think\facade\Validate;

class Upload
{
    public function index()
    {
        return View::fetch();
    }

    public function up()
    {
        $file = request()->file('image');
        $validate = Validate::rule([
            'image'=>'file|fileExt:jpg,png,gif'
        ]);
        $result = $validate->check([
            'image'=>$file
        ]);
        if($result){
            $savename = Filesystem::disk('public')->putFile( 'images', $file);
        }else {
            $error = $validate->getError();
            dump($error);
        }
    }
}